package com.adnaan.backend.entity;

import com.adnaan.backend.common.annotation.FileUrl;
import com.adnaan.backend.entity.dto.OptionDto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;
import java.util.List;

/**
 * author: adnaan
 * create: 2025-01-05 15:23
 * Description:
 */
@Data
@TableName("sys_user")
@EqualsAndHashCode(callSuper = true)//callSuper = false，即不使用父类的属性
@Tag(name = "用户表")
public class SysUser extends BaseEntity {
    /**
     * 账号
     */
    @Schema(name = "username", description = "账号")
    private String username;

    /**
     * 密码
     */
    @JsonIgnore // 忽略该字段
    @Schema(name = "password", description = "密码")
    private String password;

    /**
     * 用户的密码盐
     */
    @JsonIgnore // 忽略该字段
    @Schema(name = "salt", description = "用户的密码盐")
    private String salt;

    @JsonIgnore
    @Schema(name = "openId", description = "微信小程序登录唯一表示")
    private String openId;

    /**
     * 性别;0男1女2未知
     */
    @Schema(name = "sex", description = "性别;0男1女2未知")
    private Integer sex;

    /**
     * 昵称
     */
    @Schema(name = "nickname", description = "昵称")
    private String nickname;

    /**
     * 电话号
     */
    @Schema(name = "phone", description = "电话号")
    private String phone;

    /**
     * 邮箱
     */
    @Schema(name = "email", description = "邮箱")
    private String email;

    /**
     * 头像
     */
    @Schema(name = "avatar", description = "头像")
    @FileUrl
    private String avatar;

    /**
     * 状态;0禁用1正常
     */
    private Integer status;

    /**
     * 最后登录时间
     */
    @Schema(name = "lastLoginTime", description = "最后登录时间")
    private Date lastLoginTime;

    /**
     * 角色列表
     */
    @Schema(name = "roles", description = "角色列表")
    @TableField(exist = false)
    private List<OptionDto> roles;
}
